module ActionController
  class Base
    protected
    def self.method_dispatch(*methods)
      if methods.empty?
        before_filter :do_method_dispatch
      else
        before_filter :do_method_dispatch, :only => methods.flatten.map(&:to_sym)
      end
    end

    private
    def do_method_dispatch
      if request.post? && respond_to?("#{action_name}_post")
        eval("#{action_name}_post")
        return false
      end
    end
  end
end
